#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
using namespace std;
FILE* fp;
unsigned char c;
unsigned int characters = 0, words = 0, sentences = 0;//字符数，单词数，句子数
bool input_m(const char* name)
{
	if ((fp = fopen(name, "rb")) != NULL)  //r rb
	{
		while ((c = fgetc(fp)) != EOF)
		{
			if (((c <= 'z') && (c >= 'a')) || ((c <= 'Z') && (c >= 'A')))
			{
				characters++;
		    }  
			else if (c == ' ')
			{
				words++;
				characters++;
			}
			else if (c == '.')
			{
				sentences++;
				words++;
				characters++;
			}
			else if(c==','||c=='!'){
				characters++;
			}
			else
			{
				break;
			}
		}
		
		return 0;
	}
	else
	{
		cout << "open file error" << endl;
		return 0;
	}
}
int main()
{
	char name[100], m; //name代表文件名 m代表选择的统计输出类别
	cout << "请输入：wc.exe -";
	cin >> name;
	input_m(name);
	cin >> m;
	if (m == 'c')
	{
		cout << "字符数为:" << characters << endl;
	}
	else if (m == 'w')
	{
		cout << "单词数为:" << words << endl;
	}
	else if (m == 's')
	{
		cout << "句子数为:" << sentences << endl;
	}
}